<div class="modal-dialog " id="metaGenAttr_E_Dialog">
  <div class="modal-content">
    <div class="modal-header modal-header-condensed">
      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">×</span></button>
      <h4 class="modal-title"><i class="fa edit"></i>编辑元属性</h4>
    </div>
    <div class="modal-body" >
      <form class="form-horizontal" id="edit_form_metaGenAttr" role="form"  >
        <input type="hidden" name="attrId" id="attrId" value="${entity.id}" >
        <div class="form-group">
          <span class=" col-xs-2 control-label"> 名称</span>
          <div class=" col-xs-4">
            <input type="text" class="form-control" placeholder="属性的英文类名" name="attrName" id="attrName"  value="${entity.attrName}">
          </div>
          <span class=" col-xs-2 control-label"> 备注</span>
          <div class=" col-xs-4 ">
            <input type="text" class="form-control" placeholder="属性的中文类名" name="attrComment" id="attrComment" value="${entity.attrComment}">
          </div>
        </div>
        <div class="form-group">
          <span class=" col-xs-2 control-label"> 对应关系</span>
          <div class=" col-xs-4">
            <input type="text" class="form-control" placeholder="对象与属性的对应关系" name="relationShip" id="relationShip"  value="${entity.relationShip}">
          </div>
          <span class=" col-xs-2 control-label"> 映射类型</span>
          <div class=" col-xs-4">
            <input type="text" class="form-control" placeholder="属性的集合类型" name="relationType" id="relationType"  value="${entity.relationType}">
          </div>
        </div>
        <div class="form-group">
          <span class=" col-xs-2 control-label"> 完整类型</span>
          <div class="col-xs-4">
            <input type="text" class="form-control" placeholder="对象的完整类型" name="attrType" id="attrType"  value="${entity.attrType}">
          </div>
          <span class=" col-xs-2 control-label"> 类型</span>
          <div class=" col-xs-4">
            <input type="text" class="form-control" placeholder="对象的类型简写" name="attrShortTypeName" id="attrShortTypeName"  value="${entity.attrShortTypeName}">
          </div>
        </div>
      </form>
    </div>
    <div class="modal-footer modal-footer-condensed ">
      <button type="button" class="btn btn-default" data-dismiss="modal" >关闭</button>
      <button type="button" class="btn btn-primary" id="metaGenAttr_E_Btn">确认</button>
    </div>
  </div>
</div>
<script type="text/javascript">
  require([ "jquery","framework","validate"],function($) {
    var $container = $("#metaGenAttr_E_Dialog");
    var $parentContainer  = $container.parent();
    var reftableid = $parentContainer.data('reftableid');
    ${generateValidateJS("#edit_form_metaGenAttr","frameworkOptions.showValidateMessages","com.maker.generator.entity.MetaGenAttr","")};

    function validateAddFrom(){ 
        var editFormData = new Object();
        
        editFormData.id = $container.find('#attrId').val();
        editFormData.attrType =         $container.find('#attrType').val();
        editFormData.attrShortTypeName =      $container.find('#attrShortTypeName').val();
        editFormData.relationType =  $container.find('#relationType').val();
        editFormData.relationShip =     $container.find('#relationShip').val();
        editFormData.attrComment =     $container.find('#attrComment').val();
        editFormData.attrName =     $container.find('#attrName').val();
        if(!$container.find("#edit_form_metaGenAttr").valid()) {
            editFormData.validated = false;
        }else{
            editFormData.validated = true;
        }
        
        return editFormData;
    };
  
    
    $container.find('#metaGenAttr_E_Btn').on('click',function(e){
        var postData = validateAddFrom();
        if(postData.validated){
            delete postData.validated;
            $.ajax({
                type: "POST",
                url: "${contextPath}/metaGenAttr/edit",
                dataType:"json",
                contentType:"application/json",
                async: false,
                data:JSON.stringify(postData),
                success: function(data){
                  if("success" == data.status){
                    frameworkOptions.clearMessages();
                    frameworkOptions.showSuccessMessages(data.message);
                    $parentContainer.parent().find('#'+reftableid).bootstrapTable('refresh'); 
                    $parentContainer.modal('hide');  
                  }else if("failure" == data.status){

                    if(data.validateMessages){
                      frameworkOptions.showValidateMessages(data.validateMessages);
                    }else{
                      frameworkOptions.showErrorMessages(data.message);
                    }
                      
                  }
                    
                }
            });
        }
    });

    
    
    
  });
</script>
  